<%@ page import="javax.servlet.jsp.JspWriter" pageEncoding="utf-8"%>
<%@ page import="com.flute.haflute.monitor.ClusterStatusMonitor"%>
<%@ page import="com.flute.haflute.monitor.JobMonitorInfo"%>
<%@ page import="com.flute.haflute.monitor.JvmInfo"%>
<%@ page language="java" import="java.util.*" %>
<%
  String path = request.getContextPath();
  String ip = request.getParameter("ip");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>所有历史任务</title>
<link href="<%=path%>/css/admin.css" rel="stylesheet" type="text/css"/>
<link href="<%=path%>/css/pub.css" rel="stylesheet" type="text/css"/>
<script language="javascript" type="text/javascript" src="<%=path%>/js/jquery-1.2.6.pack.js"></script>
<script language="javascript" type="text/javascript" src="<%=path%>/js/jquery.tablesorter.min.js"></script>
<script language="javascript" type="text/javascript" src="<%=path%>/js/sort.js"></script>
</head>


<body>
<!--head start-->
<div class="header"><img src="../images/SystemName.gif" /></div>
<!--head end-->
<!--content start-->
<div class="content">
        <jsp:include page="/page/left_menu_admin.jsp" />
        <div class="right"> 
        <div class="title">所有历史任务</div>
        <table width="940" border="0" cellpadding="0" cellspacing="1" class="sortable" id="mytable"> 
        	<thead>
		  		<tr class="h_tr">
					<td width="200" height="18" bgcolor="#f3f5f8">历史作业ID</td>
					<td width="100" bgcolor="#f3f5f8">IP地址</td>
					<td width="100">子节点</td>
					<td width="80">作业状态</td>
					<td width="80" bgcolor="#f3f5f8">作业描述</td>
					<td width="130" bgcolor="#f3f5f8">作业创建时间</td>
					<td width="130" bgcolor="#f3f5f8">作业结束时间</td>
					<td width="120" bgcolor="#f3f5f8">作业监控内容</td>
		  		</tr> 
		   	</thead>
		 	<tbody>
    <%
        	List<JobMonitorInfo> histroyjobinfos = ClusterStatusMonitor.getHistroyJobInfo();
        	if (histroyjobinfos != null) {
        		for (int i = 0; i < histroyjobinfos.size(); i++) {
        			JobMonitorInfo jminfo = (JobMonitorInfo) histroyjobinfos.get(i);
        			List<String> childs = jminfo.getChilds();
        			String childstr = "";
        			String content = "";
        			if(jminfo.getStatusMessage() != null) {
        				content = jminfo.getStatusMessage().content;
        			}else{
        				content = "-";
        			}
        			if (childs != null && childs.size() > 0) {
        				for (int j = 0; j < childs.size(); j++) {
        					childstr = childstr + childs.get(j) + "<br>";
        				}
        				if (!childstr.equals("")) {
        					childstr.substring(0, childstr.length() - 1);
        				}
        			} else {
        				childstr = "-";
        			}
        %>
	    <tr>
	        <td align='left'><%=jminfo.getJobid()==null?"":jminfo.getJobid()%></td>
	    	<td align='left'><%=jminfo.getMaster()==null?"":jminfo.getMaster().toString()%></td>
	    	<td align='left'><%=childstr%></td>
	    	<td align='left'><%=jminfo.getJobstatus()==null?"":jminfo.getJobstatus().toString()%></td>
	    	<td align='left'><%=jminfo.getJobDescription()==null?"":jminfo.getJobDescription()%></td>
	    	<td align='left'><%=jminfo.getReceiveDate()==null?"-":jminfo.getReceiveDate()%></td>
	    	<td align='left'><%=jminfo.getFinishedDate()==null?"-":jminfo.getFinishedDate()%></td>
	    	<td align='left'><%=content%></td>
	    </tr>
    
    <%
        	   }
        	}
        	
        %>
        </tbody>
      </table>
    <div class="title"><input class="button" type="button" value="刷新" onClick="window.location='<%=request.getContextPath()%>/allhistoryjobs.jsp'" /></div>
	</div>
	<div class="clear"></div>
</div>
<!--content end-->
<div class="footer"></div>
</body>
</html>